﻿ 
@using LERP.Domain.Enums
@using LERP.Web.App_Start
@using Sharp.Framework
@using Sharp.Framework.Extensions

@model List<LERP.Web.Controllers.ViewModels.CustomerViewModels.CustomerViewModel>
@{
    ViewBag.Title = "客户列表";
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
}

<div id="treeDiv"  class="empty" style="text-align: left;">
    <ul class="jqueryFileTree">
        @foreach (var item in Model.Where(m => m.Level == CustomerLevel.First))
        {
            var list = Model.Where(x => x.ParentId == item.Id);
            <li class="directory collapsed">
                <span>  <a  class="treename">@item.Name   </a> 
                </span>
                <ul class="jqueryFileTree">
                    @foreach (var second in list)
                    {
                        var thirds = Model.Where(x => x.ParentId == second.Id);
                        <li class="directory collapsed">
                            <span>  <a  class="treename">@second.Name   </a> 
                            </span>
                            <ul class="jqueryFileTree">
                                @foreach (var node in thirds)
                                {

                                    <li class="file ext_code">
                                        <span><a  class="treename">@node.Name</a>
                                           
                                            <a  class="action" id="@node.Id" title="@(item.Name+second.Name+node.Name)">选择</a>
                                        </span>
                                    </li>
                                }
    
                            </ul>
                        </li>
                    }
    
                </ul>
            </li>

        }
    </ul>
</div>


@section Scripts {
    <script type="text/javascript">

        $(function () {
            $("a.action").click(function () {
                window.opener.document.getElementById("CustomerId").value = this.id;
                window.opener.document.getElementById("Customer").value = this.title;
                window.close();
            });

        })

    </script>

}
